/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.dataprocessing.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.icinfo.cloud.provider.punish.csource.manage.model.CaseSourceRegisterMainInfo;
import com.icinfo.cloud.provider.punish.dataprocessing.dto.CaseSearchDto;
import com.icinfo.cloud.provider.punish.dataprocessing.mapper.DataProcessCaseSourceMainInfoDelRecordMapper;
import com.icinfo.cloud.provider.punish.dataprocessing.model.DataProcessCaseSourceMainInfoDelRecord;
import com.icinfo.cloud.provider.punish.dataprocessing.service.IDataProcessCaseSourceMainInfoDelRecordService;
import com.icinfo.framework.core.service.support.MyBatisServiceSupport;
import com.icinfo.framework.mybatis.mapper.entity.Example;
import com.icinfo.framework.mybatis.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 描述: 工单处理-案源删除备份表 data_process_case_source_main_info_del_record 对应的Service接口实现类.<br>
 *
 * @author framework generator
 * @date 2023年02月02日
 */
@Service
public class DataProcessCaseSourceMainInfoDelRecordServiceImpl extends MyBatisServiceSupport implements IDataProcessCaseSourceMainInfoDelRecordService {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(DataProcessCaseSourceMainInfoDelRecordServiceImpl.class);

    @Autowired
    private DataProcessCaseSourceMainInfoDelRecordMapper dataProcessCaseSourceMainInfoDelRecordMapper;

    /**
     * 保存记录
     *
     * @param caseSourceMainInfoDelRecord 案源删除记录
     * @author lilihao
     * @date 2023/2/8 0:52
     */
    @Override
    public void saveRecord(DataProcessCaseSourceMainInfoDelRecord caseSourceMainInfoDelRecord) {
        dataProcessCaseSourceMainInfoDelRecordMapper.insert(caseSourceMainInfoDelRecord);
    }

    /**
     * 获取案源删除信息
     * @param searchDto 查询dto
     * @return  案源信息
     * @author lilihao
     * @date 2023/2/6 19:14
     */
    @Override
    public List<DataProcessCaseSourceMainInfoDelRecord> getCaseSourceRegisterInfo(CaseSearchDto searchDto) {
        PageHelper.startPage(1, 10);
        Example example = new Example(DataProcessCaseSourceMainInfoDelRecord.class);
        if (StrUtil.isNotBlank(searchDto.getId())){
            example.createCriteria().andEqualTo("id",searchDto.getId());
        }

        if (StrUtil.isNotBlank(searchDto.getCaseName())){
            example.createCriteria().andLike("caseSourceName","%"+searchDto.getCaseName());
        }

        if (StrUtil.isNotBlank(searchDto.getCaseDesc())){
            example.createCriteria().andLike("caseSourceDesc","%"+searchDto.getCaseDesc());
        }

        if (StrUtil.isNotBlank(searchDto.getCaseActsCode())){
            example.createCriteria().andEqualTo("caseSourceAppActsCode",searchDto.getCaseActsCode());
        }
        return  dataProcessCaseSourceMainInfoDelRecordMapper.selectByExample(example);
    }
}